package com.fu.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author 付大大
 * @description 定时刷新
 * @create 2021-01-24 17:25
 */
@WebServlet("/servletDemo05")
public class ServletDemo05 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String str = "用户名或者密码有误,三秒后自动跳转到登录页面";
        resp.setContentType("text/html;charset=UTF-8");
        resp.getWriter().write(str);
        //定时刷新
        resp.setHeader("Refresh","3;URL=/response/login.html");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
